﻿using UnityEngine;
using System;

public class ToolBar : GUIX.Canvas
{
		public ToolBar_Logic _logicHandler;
		public GUIX.Toolbar Toolbar;
		public GUIX.Label Label;
		public GUIX.DrawTexture _texture;
		public Texture _ptexture;
	
		public ToolBar()
		{
			Init();
		}

		public override void Init()
		{
			_logicHandler = new ToolBar_Logic();
			_logicHandler.Init(this);
			CanvasLanguage = "cs";
			Rect = new Rect(0.0F, 0.0F, Screen.width+2, Screen.height);

			this.CanvasName = "ToolBar";

			//// Label ////
			Label = new GUIX.Label(this);
			Label.ElementName = "Label";
			Label.Rect = new Rect(45F, 45F, 12.8F, 3.5F);
			Label.LayoutMode = GUIX.ElementBase.ElementLayoutMode.Relative;
			Label.Text = @"AHSDGASGDH";
			Label.ClickEvent += _logicHandler.Label_Click;
			Label.MouseOverEvent += _logicHandler.Label_MouseOver;
			Label.MouseOutEvent += _logicHandler.Label_MouseOut;
			Label.Rotation = 0;
			Label.Color = new Color(1F, 1F, 1F, 1F);
			Label.AutoSize = GUIX.ElementBase.AutoSizeMode.None;
			Label.AutoSizeAnchor = GUIX.ElementBase.AutoSizeAnchorType.TopLeft;
			Label.AutoSizeMinScale = new Vector2(0F, 0F);
			Label.AutoSizeMaxScale = new Vector2(100F, 100F);
			Label.IsVisible = true;
			Label.HandleClick = true;
			Label.TooltipText = "";

			this.AddElement( Label );
			Custom();
		}
		void Custom()
		{
			//// Label ////
			_texture = new GUIX.DrawTexture(this);
			_texture.ElementName = "DrawTexture";
			_texture.ScaleMode = ScaleMode.StretchToFill;
			_texture.Rect = new Rect(
				0f,
				Rect.height - 180f,
				Rect.width, 
				180.0f);
			Debug.Log(Rect);
			Debug.Log(_texture.Rect);
			_texture.LayoutMode = GUIX.ElementBase.ElementLayoutMode.Absolute;
			_texture.Rotation = 0;

			_texture.IsVisible = true;
			_texture.HandleClick = false;
			_texture.Texture = _ptexture;
			this.AddElement( _texture );
		}
	public Texture Textu{
			get{return _ptexture; }
			set{
				_ptexture = value; 
				_texture.Texture=_ptexture;
			}
		}
}
